/**
 * Fisher-Yates shuffle
 * 
 * To shuffle an array a of n elements (indices 0..n-1):
 *  for i from n - 1 downto 1 do
 *      j = random integer with 0 =< j =< i
 *      exchange a[j] and a[i]
 */
function shuffleArray(array) {
	var i, j, tmp;
	for (i = array.length -1; i > 0; --i) {
		j = Math.floor(Math.random() * i);
		tmp = array[i];
		array[i] = array[j];
		array[j] = tmp;
	}
	return array;
}
function testShuffleArray() {
	console.log(shuffleArray([]));
	console.log(shuffleArray([1]));
	console.log(shuffleArray([1, 2]));
	console.log(shuffleArray([1, 2, 3]));
	console.log(shuffleArray([1, 2, 3, 4]));
}
//testShuffleArray();

function extend(subClass, baseClass) {
   function inheritance() {}
   inheritance.prototype = baseClass.prototype;

   subClass.prototype = new inheritance();
   subClass.prototype.constructor = subClass;
   subClass.baseConstructor = baseClass;
   subClass.superClass = baseClass.prototype;
}
